package com.ruicar.afs.cloud.account.common.controller;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruicar.afs.cloud.account.common.condition.AccountVoucherInfoCondition;
import com.ruicar.afs.cloud.account.common.entity.AccountVoucherInfo;
import com.ruicar.afs.cloud.account.common.service.AccountVoucherInfoService;
import com.ruicar.afs.cloud.common.core.query.QueryCondition;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/7/5 18:55
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/accountVoucherInfo")
@Api(value = "accountVoucherInfo", description = "凭证信息")
public class AccountVoucherInfoController {
    private final AccountVoucherInfoService accountVoucherInfoService;

    @PostMapping("/getAccountVoucherInfoList")
    @ApiOperation(value = "获取凭证信息")
    public IResponse<Object> getAccountVoucherInfoList(@RequestBody QueryCondition<AccountVoucherInfoCondition> condition) {
       return IResponse.success(accountVoucherInfoService.getAccountVoucherInfoList(condition));
    }

    @PostMapping("/getVoucherInfo/{id}")
    @ApiOperation(value = "获取凭证明细信息")
    public IResponse getVoucherInfo(@PathVariable String id) {
        return IResponse.success(accountVoucherInfoService.getVoucherInfo(Long.parseLong(id)));
    }

    @PostMapping("/reversal/{id}")
    @ApiOperation(value = "冲销凭证信息")
    public IResponse reversal(@PathVariable String id) {
        return IResponse.success(accountVoucherInfoService.reversal(Long.parseLong(id)));
    }
    @PostMapping("/resend/{id}")
    @ApiOperation(value = "重新发送凭证信息")
    public IResponse resend(@PathVariable String id) {
        return IResponse.success(accountVoucherInfoService.resend(Long.parseLong(id)));
    }
    @PostMapping("/exportVoucherList")
    @ApiOperation(value = "导出凭证信息")
    public IResponse exportVoucherList(@RequestBody QueryCondition<AccountVoucherInfoCondition> condition) {
        return IResponse.success(accountVoucherInfoService.exportVoucherList(condition));
    }
}
